<%@ page import="com.html5.utils.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String language=request.getParameter("hl");
%>

<html>
<base href="<%=basePath%>">

<%
	if(language!=null && language.length()>0){
		Constant.language=language;
	}else if("".equals(Constant.language)){
		//language=Constant.language;
	}
%>

<script>
   
	var req = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
	var body,uri;
	var loc='<%=Constant.language%>';
	var param='<%=language%>';
	var local=window.localStorage.getItem("hl");
	if(local){
		local=(local!="Chinese")?"en":"zh-cn";
	}else{
		local="en";
	}
	if(param!='null'){
		window.localStorage.setItem("url",param);
	}else if(local!=param && param=='null' && local!=loc){
		req.onreadystatechange = function() {
	        if (req.readyState == 4) {
	        	console.log("chang language success!");
	        	document.location.href = document.location.toString();
	            
	        } 
	    }
	    req.open('POST', 'html5-show/language', true);
	    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    req.send(local);
	}
	
</script>

<%if(Constant.language!=null){ %>
	<c:set var="loc" value="<%=Constant.language %>"/>
<%} %>
<fmt:setLocale value="${loc}" />